﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;
using GalaSoft.MvvmLight.Messaging;
using ProjectWizardManagementv1.ViewModels;
using ProjectWizardManagementv1.Views;

namespace ProjectWizardManagementv1
{
    public partial class MainWindow : Window
    {
        private Dictionary<ViewModelKey, UserControl> _mainViews;
 
        public MainWindow()
        {
            InitializeComponent();
            Messenger.Default.Register<ViewModelKey>(this, SwapView);
            InitializeMainViews();
            SwapView(ViewModelKey.ProjectDialog);
        }

        private void InitializeMainViews()
        {
            _mainViews = new Dictionary<ViewModelKey, UserControl>
                             {
                                 {ViewModelKey.ProjectDialog, new ProjectDialog()},
                                 {ViewModelKey.Workspace, new Workspace()},
                             };
        }

        public void SwapView(ViewModelKey key)
        {

            UserControl userControl = _mainViews[key];
            LayoutRoot.Children.Clear();
            LayoutRoot.Children.Add(userControl);
            this.SizeToContent = SizeToContent.WidthAndHeight;
        }
    }
}
